﻿namespace TianlalaHSB.Models;

public class Paginate<T>
{
    public Paginate()
    {
    }

    public Paginate(int current, int size, int limit = 10)
    {
        curr = current;
        count = size;
        this.limit = limit;
        first = 1;
        last = (int)Math.Ceiling((double)count / limit);
        prev = Math.Max(first, curr - 1);
        next = Math.Min(last, curr + 1);
    }

    /// <summary>
    ///     列表
    /// </summary>
    public List<T>? records { get; set; }

    /// <summary>
    ///     数据总数
    /// </summary>
    public int count { get; set; }

    /// <summary>
    ///     每页显示的条数
    /// </summary>
    public int limit { get; set; }

    /// <summary>
    ///     当前页码
    /// </summary>
    public int curr { get; set; }

    /// <summary>
    ///     首页
    /// </summary>
    public int first { get; set; }

    /// <summary>
    ///     尾页
    /// </summary>
    public int last { get; set; }

    /// <summary>
    ///     上一页
    /// </summary>
    public int prev { get; set; }

    /// <summary>
    ///     下一页
    /// </summary>
    public int next { get; set; }
}